package service

import (
	"github.com/gin-gonic/gin"
	"time"
	"zk2/product-guard/internal/dto"
	"zk2/product-guard/internal/model"
	"zk2/product-guard/response"
)

func CreateOrder(c *gin.Context) {

	var order model.Order
	err := c.ShouldBind(&order)
	if err != nil {
		response.Error(c, "参数错误")
		return
	}
	order = model.Order{
		ShopId: order.ShopId,
		UserId: order.UserId,
		Year:   time.Now(),
		Status: order.Status,
	}
	err = dto.CreateOrder(&order)
	if err != nil {
		response.Error(c, "订单生成失败")
		return
	}
	response.Success(c, "订单生成成功", order.ID)
}
